package org.nox.helloseries.rest.client.configuration.impl;

import java.util.List;

import org.nox.helloseries.domain.NomTracker;
import org.nox.helloseries.domain.Serie;
import org.nox.helloseries.domain.Tracker;
import org.nox.helloseries.rest.client.AbstractRESTRequestService;
import org.nox.helloseries.rest.client.configuration.RESTConfigurationService;

import com.fasterxml.jackson.core.type.TypeReference;

public class DefaultRESTConfigurationService extends AbstractRESTRequestService implements RESTConfigurationService
{

    @Override
    public List<Tracker> getTrackersActifs()
    {
        return executeGETRequest( "trackers?active=true", new TypeReference<List<Tracker>>()
        {
        } );
    }

    @Override
    public Tracker getTracker( NomTracker nomTracker )
    {
        return executeGETRequest( "tracker/" + nomTracker, Tracker.class );
    }

    @Override
    public List<Serie> getSeriesActives()
    {
        return executeGETRequest( "series?active=true", new TypeReference<List<Serie>>()
        {
        } );
    }

    @Override
    public List<Serie> getSeries()
    {
        return executeGETRequest( "series", new TypeReference<List<Serie>>()
        {
        } );
    }

    @Override
    public void saveSeries( List<Serie> series )
    {
        executePOSTRequest( "series", series );
    }

    @Override
    public void updateTrackers( List<Tracker> trackers )
    {
        executePOSTRequest( "trackers", trackers );
    }

    @Override
    public String getParentResourceName()
    {
        return "configuration";
    }

}
